<?php 

include '../functions.php';

// 链接数据库

$res  = @mysql_connect("localhost",'root','');

if(!$res){
	exit("错误代码：".mysql_errno()."错误原因：".mysql_error());
}
// 选择库
$res = mysql_select_db("school");

if(!$res){
	exit("错误代码：".mysql_errno()."错误原因：".mysql_error());
}
// 设置字符集
mysql_query("set names utf8");


$sql = "insert into stu (name,age,sex) values('小马',18,'男')";

// $sql = "update stu set age=30 where name='小花'";


// $sql = "delete from stu where sid =5";

$res = mysql_query($sql);


// var_dump(mysql_insert_id());


// if(!$res){
// 	exit("错误代码：".mysql_errno()."错误原因：".mysql_error());
// }

exit;
$sql = "select * from stu t1 inner join class t2 on t1.cid=t2.cid";


$res = mysql_query($sql);

// var_dump(mysql_num_rows($res));

if(!$res){
	exit("错误代码：".mysql_errno()."错误原因：".mysql_error());
}

$temArr = [];


while ( $row = mysql_fetch_assoc($res)) {
	$temArr[] = $row;
}


var_dump($temArr);

mysql_free_result($res);

mysql_close();


 ?>